package com.asiainfo.www.function;

import com.asiainfo.www.pojo.StatFile;
import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.api.java.tuple.Tuple0;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.util.Collector;

/**
 * @author loso
 */
public class StatFileFlatMap implements FlatMapFunction<String, StatFile> {
    private static final long serialVersionUID = 1L;

    @Override
    public void flatMap(String value, Collector<StatFile> out) {
        String[] tokens = value.split(";");
        if (tokens.length!=5) {
            return;
        }
        for (int i = 0; i < tokens.length; i++) {
            tokens[i] = tokens[i].split(":")[1];
        }
        StatFile statFile = new StatFile(tokens);
        out.collect(statFile);
    }
}
